﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace JoeyLibs.IdleStartMenu.WPFUI
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        private UserViewModel viewModel;

        public Window1()
        {
            InitializeComponent();
            viewModel = new UserViewModel();
            this.DataContext = viewModel.User;
        }
    }

    class UserModel : INotifyPropertyChanged
    {
        public int ID { get; set; }

        private string name;
        public string Name 
        { 
            get { return this.name; }
            set 
            { 
                this.name = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

    class UserViewModel
    {
        public UserModel User { get; set; }

        //private UserModel users;
        public IList<UserModel> Users { get; set; }

        public UserViewModel()
        {
            User = new UserModel { ID=1, Name="aa" };
            User.PropertyChanged += User_PropertyChanged;
        }

        void User_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            throw new NotImplementedException();
        }
    }
}
